Date Formats
This script helps you format your dates in a variety of ways. These
functions, which convert month and date numbers into strings,
each use the function doIndex(),
which addresses a string as if it were an array.
//------------------STRING-ARRAY UTILITY-------------------
// Find the substring at index n, counting 0 to n
function doIndex(aString, n)
{
var str=""+aString
// Count until the correct index
for(var i = 0; i < n; i++)
{
var where = str.indexOf(':', 1)
str = str.substring(where+1, str.length)
}
// Lop off the end of the string
return str.substring(0, str.indexOf(':'))
}
// --------------------DATE STRING UTILITIES---------------------
// Return the 3-letter symbol for month #n
function month(n)
{
var m = "Jan:Feb:Mar:Apr:May:Jun:Jul:Aug:Sep:Oct:Nov:Dec:"
return doIndex(m, n)
}
Copyright ©1998 by Charles River Media, All Rights Reserved